package com.cote.douhahou.pretloan.home;

import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.view.ViewGroup;

import androidx.annotation.NonNull;

import com.cote.douhahou.pretloan.network.HttpHelper;
import com.google.android.material.bottomsheet.BottomSheetDialog;
import com.cote.douhahou.pretloan.R;


public class ProcessShowDialog extends BottomSheetDialog {

    private final String flag;
    private final Runnable buttonRunnable;

    public ProcessShowDialog(@NonNull Context context, String flag, Runnable buttonRunnable) {
        super(context, R.style.Theme_AkomapaLend_BottomDialogStyle);
        this.flag = flag;
        this.buttonRunnable = buttonRunnable;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.dialog_show_process);
        getWindow().setBackgroundDrawableResource(R.color.transparent);
        getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
        getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);

        findViewById(R.id.dpa_btn_apply).setOnClickListener(v -> {

            HttpHelper.inst().submitEvent(flag,"APPLY_CLICK","");
            dismiss();
            if (buttonRunnable !=null) buttonRunnable.run();
        });
    }


}
